# $Id: PKGBUILD 78838 2012-10-25 13:06:43Z stephane $
# Maintainer: Stéphane Gaudreault <stephane@archlinux.org>
# Contributor: Thomas Dziedzic < gostrc at gmail >
# Contributor: Angel 'angvp' Velasquez <angvp[at]archlinux.com.ve>  
# Contributor: Peter Garceau <RockyChimp@gmail.com>

pkgbase=python-sympy
pkgname=('python2-sympy' 'python-sympy')
pkgver=0.7.2
pkgrel=1
arch=('any')
pkgdesc='Symbolic manipulation package (Computer Algebra System), written in pure Python'
url='http://sympy.org/en/index.html'
license=('BSD')
makedepends=('python2' 'python')
optdepends=('pyglet: plotting'
            'ipython2: user friendly interface for isympy')
source=("http://sympy.googlecode.com/files/sympy-${pkgver}.tar.gz"
        "http://sympy.googlecode.com/files/sympy-${pkgver}-py3.2.tar.gz")
md5sums=('480185006fb318f5c9bbd75b4cf9771d'
         'a90621bf4c0678c35e67ed62a56196f1')
noextract=(sympy-${pkgver}-py3.2.tar.gz)

build() {

  cd "${srcdir}"
  mkdir -p py3
  tar zxf sympy-${pkgver}-py3.2.tar.gz -C py3

  # Build python 2 module 
  cd sympy-${pkgver}
  sed -i 's|#!/usr/bin/python|#!/usr/bin/python2|' sympy/galgebra/GA.py sympy/galgebra/tests/test_GA.py
  sed -i 's|#!/usr/bin/env python|#!/usr/bin/env python2|' sympy/mpmath/tests/runtests.py
  python2 setup.py build

  # Build python 3 module 
  cd ../py3/sympy-${pkgver}
  sed -i 's|#!/usr/bin/python|#!/usr/bin/python3|' sympy/galgebra/GA.py sympy/galgebra/tests/test_GA.py
  sed -i 's|#!/usr/bin/env python|#!/usr/bin/env python3|' sympy/mpmath/tests/runtests.py
  python3 setup.py build

}

#check() {
#  cd sympy-${pkgver}
#  python2 setup.py test
#   
#  cd py3/sympy-${pkgver}
#  python3 setup.py test
#
#}

package_python2-sympy() {
  depends=('python2>=2.7')
  optdepends=('pyglet: plotting'
              'ipython2: user friendly interface for isympy')

  cd sympy-${pkgver}

  python2 setup.py install --root "${pkgdir}" --optimize=1

  install -D -m644 LICENSE "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
}

package_python-sympy() {
  depends=('python>=3.3')
  optdepends=('ipython: user friendly interface for isympy')

  cd py3/sympy-${pkgver}

  python3 setup.py install --root "${pkgdir}" --optimize=1

  # rename files that exists in both 'python2-sympy' and 'python-sympy'
  mv "${pkgdir}"/usr/bin/isympy{,-py3}
  mv "${pkgdir}"/usr/share/man/man1/isympy{,-py3}.1

  install -D -m644 LICENSE "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
}
